import sys
import os
# sys.path.append(os.path.dirname(__file__))
# print(sys.path)

from get_data import requests_get

from lib import common
#print(os.path.dirname(__file__))#--> D:/mysqldb/pycharm move/pycharm xiangmu/01/py3.9

def ths()->dict:
    code="同花顺top100"
    return requests_get.choose(code)

def dfcf()->dict:
    code="东方财富top100"
    return requests_get.choose(code)
def dfcf_rank_now()->str:
    #"东方财富实时rank"  api->requests_get.Dfcf_rank(input_code,"now实时").hot_rank()
    input_code=input("请输入股票代码")
    print("{}当前人气排名{}".format(input_code,requests_get.Dfcf_rank(input_code,"now实时").hot_rank))

def dfcf_rank_history() ->str:
    #"东方财富历史rank" api-> requests_get.Dfcf_rank(input_code,"his历史").hot_rank()
    input_code=input("请输入股票代码")
    print("{}人气时间历史{}".format(input_code,requests_get.Dfcf_rank(input_code,"his历史").hot_rank))
    pass
def dxw_yd():
    requests_get.dxw.yidong()
    print("已经保存到yidong中")
def dxw_zt():
    requests_get.dxw.zhangting()
    print("已经保存到yidong中")
def xx():
    print("还在练习中，请加油")
    pass
func_dict={ "1":["->同花顺top100",ths],
            "2":["->东方财富top100",dfcf],
            "3":["->东方财富实时rankX",dfcf_rank_now],
            "4":["->东方财富历史rankX",dfcf_rank_history],
            "5":["->dxw异动",dxw_yd],
            "5.1":["->dxw涨停 ,6.1涨停15天",xx],
            "5.2":["->dxw涨停与龙虎榜 ,6.1涨停15天",xx],
            "5.3": ["->dxw个股资金", xx],
            "6.1":["->search 人气",xx],
            "6.2":["->search 成交量",xx],
            "6.3":["->search 250均线",xx]

           }
def run():
    while True:
        print("""
        =================================
        1.当日同花顺top100(缺点：没历史数据，反爬对爬虫要求高)
        2.当日东方财富top100(缺点：没历史数据)
        3.东方财富实时rankX(缺点：当日历史数据，没追溯功能)
        4.东方财富历史rankX(缺点：短期历史数据，没追溯功能)
        5.dxw异动
        5.1.dxw异动累计
        5.2 涨停与龙虎榜
        =================================
        """)
        choice=input("请输入功能:")
        if choice not in func_dict:
            print("请输入正确数字")
            continue
        print(func_dict[choice][0])
        func_dict[choice][1]()
if __name__ == '__main__':
    from lxml import html

    run()





